<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            width: 100vw;
            height: 100vh;
        }
    </style>
</head>
<body>
    <h1>aaaaaaaaaa</h1>
    <button onclick="showIframe()">showIframe</button>

    <script>
        function showIframe() {
            const e = document.createElement('iframe');
            e.src = '/test.html';
            e.width = document.body.clientWidth - 100;
            e.height = document.body.clientHeight - 50;;
            e.onload = function() {
                const doc = e.contentDocument || e.contentWindow.document;
                console.log('doc: ', doc.readyState)
            }
            document.body.appendChild(e);
        }
    </script>
</body>
</html>